package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.SchoolContacts;
import cn.wolfcode.crm.mapper.SchoolContactsMapper;
import cn.wolfcode.crm.query.QueryForObject;
import cn.wolfcode.crm.service.ISchoolContactsService;
import cn.wolfcode.crm.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BigSchoolContactsImpl implements ISchoolContactsService {

    @Autowired
    private SchoolContactsMapper schoolContactsMapper;

    public void deleteByPrimaryKey(Long id) {
        schoolContactsMapper.deleteByPrimaryKey(id);
    }

    public void insert(SchoolContacts schoolContacts) {
        schoolContactsMapper.insert(schoolContacts);
    }

    public SchoolContacts selectByPrimaryKey(Long id) {
        return schoolContactsMapper.selectByPrimaryKey(id);
    }

    public List<SchoolContacts> selectAll() {
        return schoolContactsMapper.selectAll();
    }

    public void updateByPrimaryKey(SchoolContacts schoolContacts) {
        schoolContactsMapper.updateByPrimaryKey(schoolContacts);
    }

    public PageResult queryListByQo(QueryForObject qo) {
        int total = schoolContactsMapper.getTotalByQo(qo);
        if (total == 0) {
            return new PageResult();
        }
        List<SchoolContacts> rows = schoolContactsMapper.getListByQo(qo);
        return new PageResult(total, rows);
    }

    public void contract(Long id) {
        schoolContactsMapper.contract(id);
    }
}
